package operation;
import book.BookList;
import book.Book;
import java.util.Scanner;

public class BorrowOperation implements IOperation {
    public void work(BookList bookList) {
        System.out.println("****借阅图书****");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入您要借阅的书名: ");
        String name = scanner.nextLine();

        int currentSize = bookList.getUsedSize();
        for(int i = 0;i < currentSize;i++) {
            Book book = bookList.getBook(i);
            if(book.getName().equals(name)) {
                book.setBorrowed(true);
                System.out.println("借阅成功!");
                return;
            }
        }
        System.out.println("不存在该书!");
    }
}
